package com.campus.shop.service.impl;

import com.campus.shop.entity.UserSaleInfo;
import com.campus.shop.mapper.UserSaleInfoMapper;
import com.campus.shop.service.UserSaleInfoService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.campus.shop.common.ConstantProperties;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;

/**
 * 卖家信息表 服务实现类
 * @author xr
 * @since 2023-12-360 14:50:41
 */
@Service
        public class UserSaleInfoServiceImpl extends ServiceImpl<UserSaleInfoMapper, UserSaleInfo>implements UserSaleInfoService {
        @Autowired
        private UserSaleInfoMapper UserSaleInfoMapper;

        @Override
        public Boolean insertUserSaleInfo(UserSaleInfo userSaleInfo){
        return this.save(userSaleInfo);
        }

        @Override
        public Boolean updateUserSaleInfo(UserSaleInfo userSaleInfo){
        return this.updateById(userSaleInfo);
        }

        @Override
        public Boolean deleteUserSaleInfo(Long id){
        return this.removeById(id);
        }

        @Override
        public UserSaleInfo queryById(Long id){
        return this.getById(id);
        }

        @Override
        public HashMap<String,Object>pageList(Integer currentPage){
        QueryWrapper<UserSaleInfo>queryWrapper=new QueryWrapper<>();
        Page<UserSaleInfo> UserSaleInfopage=new Page<>(currentPage,ConstantProperties.limit);
        Page<UserSaleInfo>page= UserSaleInfoMapper.selectPage(UserSaleInfopage,queryWrapper);
        List<UserSaleInfo>list=page.getRecords(); //当前页数数据
        long total=page.getTotal(); //总条数
        HashMap<String,Object>res=new HashMap<>();
        res.put("total",total);
        res.put("list",list);
        return res;
        }
        }

